<!DOCTYPE html>
<#assign f = JspTaglibs["http://www.casic304.cn/f"] />
<#assign dicSelect = JspTaglibs["http://www.casic304.cn/dicSelect"]/>
<html>
<head>
    <meta charset="utf-8">
    <title>飞行试验奖惩计划管理信息列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/style/qbdms.css">
    <script type="text/javascript">
        var __ctx = "${ctx}";

    </script>
</head>
<body class="listBody">
<div class="qbdms-list">
    <div class="layui-table-view-body">
    <table id="wQbdFlightJcTable" lay-filter="wQbdFlightJcTable"></table>
    </div>
</div>
<!-- 列表头部工具栏 -->
<script type="text/html" id="wQbdFlightJcHeaderToolsBar">
    <div class="ccpui-enterSel">
        <div class="layui-btn-container">
            <@f.a alias="fxsyjcjhdcan" event="export" css="layui-btn layui-btn-sm" >
                <span>导出</span>
            </@f.a>
        </div>
        <form class="layui-form" action="" lay-filter="wQbdFlightJcQueryForm">
            <div class="layui-form-body selch">
                <div class="table-top-filter layui-row">
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">年度</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input filter-value dateTimeFiled time-init year" name="Q_nd_S" placeholder="请输入"/>
                        </div>
                    </div>
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">型号名称</label>
                        <div class="layui-input-block">
                            <select name="Q_xhmc_SL" class="layui-input filter-value" lay-verify="required" lay-search=""></select>
                        </div>
                    </div>
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">项目类型</label>
                        <div class="layui-input-block">
                            <@dicSelect.dic name="Q_xmlx_SL" css="layui-input filter-value" search=true nodeKey="xmlx" />
                        </div>
                    </div>

                    <div class="qbdms-listForm">
                        <label class="layui-form-label">项目类别</label>
                        <div class="layui-input-block">
                            <@dicSelect.dic name="Q_xmlb_SL" css="layui-input filter-value" search=true nodeKey="xmlb" />
                        </div>
                    </div>
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">项目阶段</label>
                        <div class="layui-input-block">
                            <@dicSelect.dic name="Q_xmjd_SL" css="layui-input filter-value" search=true nodeKey="xmjd" />
                        </div>
                    </div>
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">飞行试验名称</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input filter-value" name="Q_fxsymc_SL" placeholder="请输入"/>
                        </div>
                    </div>
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">项目主管部门</label>
                        <div class="layui-input-block">
                            <@dicSelect.dic name="Q_zgbm_SL" css="layui-input filter-value" search=true nodeKey="zgbm" />
                        </div>
                    </div>
                </div>
                <div class="selchBtn">
                    <a class="layui-btn layui-btn-sm fillBtn" lay-event="query">
                        <span>查询</span>
                    </a>
                    <div class="layui-btn-group">
                        <button type="button" class="layui-btn layui-btn-sm" lay-event="clears"
                                style="width: 28px;font-size: 12px;padding: 0">
                            <i class="iconfont  data-iconcommon_refresh"></i>
                        </button>
                        <button type="button" class="layui-btn layui-btn-sm screenParent" lay-event="screen"
                                style="width: 28px;font-size: 12px;padding: 0">
                            <i class="iconfont data-iconcommon_downarrow screen"></i>
                        </button>
                    </div>
                </div>
            </div>
        </form>
    </div>

</script>

<script id="jlswmc" type="text/html">
    {{# layui.each(d.wQbdFlightJczbList, function(index, item){ }}
    <span >
           {{ item.jlswmc|| '' }}
        </span>
    {{# }); }}
    {{# if(d.wQbdFlightJczbList.length === 0){}}
    <span style="text-align: left">
           {{  '-' }}
        </span>
    {{# } }}
</script>

<script id="fpbl" type="text/html">
    {{# layui.each(d.wQbdFlightJczbList, function(index, item){ }}
    <span style="color: #F07878;text-align: right">
           {{ item.fpbl|| '' }}
        </span>
    {{# }); }}
    {{# if(d.wQbdFlightJczbList.length === 0){}}
    <span style="text-align: right">
           {{  '-' }}
        </span>
    {{# } }}
</script>


<script id="sjjled" type="text/html">
    {{# layui.each(d.wQbdFlightJczbList, function(index, item){ }}
    <span class="layui-table-cell" style="color: #F07878;text-align: right">
           {{ item.sjjled|| 0}}
        </span>
    {{# }); }}
    {{# if(d.wQbdFlightJczbList.length === 0){}}
    <span class="layui-table-cell" style="color: #F07878;text-align: right">
           {{  0 }}
        </span>
    {{# } }}
</script>



<script id="sjcfed" type="text/html">
        {{# layui.each(d.wQbdFlightJczbList, function(index, item){ }}
        <span class="layui-table-cell" style="color: #F07878;text-align: right">
           {{ item.sjcfed|| 0}}
        </span>
        {{# }); }}
        {{# if(d.wQbdFlightJczbList.length === 0){}}
        <span class="layui-table-cell" style="color: #F07878;text-align: right">
           {{  0 }}
        </span>
        {{# } }}
</script>
<script id="syjg" type="text/html">
    {{# layui.each(d.wQbdFlightJczbList, function(index, item){ }}
    <span class="layui-table-cell" style="text-align: right">
           {{ item.syjg|| '-'}}
        </span>
    {{# }); }}
    {{# if(d.wQbdFlightJczbList.length === 0){}}
    <span class="layui-table-cell" style="text-align: right">
           {{  '-' }}
        </span>
    {{# } }}
</script>
<!-- 右侧工具栏 -->
<script type="text/html" id="wQbdFlightJcRightToolsBar">

    <div style="height:{{(d.wQbdFlightJczbList.length || 1)*38}}px" class="RightBtn" lay-event="particulars">详情</div>

</script>
<style>
    .layui-table-cell{
        height: auto;
    }


    td[data-field="jlswmc"]{
        padding: 0px !important;
    }
    td[data-field="jlswmc"] > div{
        padding: 0 !important;
        /*height: auto;*/
    }
    td[data-field="jlswmc"] > div > span{
        display: block;
        border-top: 1px solid #e6e6e6;
        text-align: center;
        width: 142px;
        text-overflow: ellipsis;
        white-space: nowrap;
        overflow: hidden;
        padding-left: 15px;
        padding-right: 15px;
    }
    td[data-field="jlswmc"] > div > span:nth-child(1){
        border-top: 0px;
    }


    td[data-field="fpbl"]{
        padding: 0px !important;
    }
    td[data-field="fpbl"] > div{
        padding: 0 !important;
        height: auto;
    }
    td[data-field="fpbl"] > div > span{
        display: block;
        border-top: 1px solid #e6e6e6;
        text-align: center;
    }
    td[data-field="fpbl"] > div > span:nth-child(1){
        border-top: 0px;
    }

    td[data-field="sjjled"]{
        padding: 0px !important;
    }
    td[data-field="sjjled"] > div{
        padding: 0 !important;
        height: auto;
    }
    td[data-field="sjjled"] > div > span{
        display: block;
        border-top: 1px solid #e6e6e6;
        text-align: center;
    }
    td[data-field="sjjled"] > div > span:nth-child(1){
        border-top: 0px;
    }


    td[data-field="sjcfed"]{
        padding: 0px !important;
    }
    td[data-field="sjcfed"] > div{
        padding: 0 !important;
        height: auto;
    }
    td[data-field="sjcfed"] > div > span{
        display: block;
        border-top: 1px solid #e6e6e6;
        text-align: center;
    }
    td[data-field="sjcfed"] > div > span:nth-child(1){
        border-top: 0px;
    }



    td[data-field="syjg"]{
        padding: 0px !important;
    }
    td[data-field="syjg"] > div{
        padding: 0 !important;
        /*height: auto;*/
    }
    td[data-field="syjg"] > div > span{
        display: block;
        border-top: 1px solid #e6e6e6;
        text-align: center;
        width: 80px;
        text-overflow: ellipsis;
        white-space: nowrap;
        overflow: hidden;
        padding-left: 15px;
        padding-right: 15px;
    }
    td[data-field="syjg"] > div > span:nth-child(1){
        border-top: 0px;
    }


</style>
<script src="${ctx}/qbdmsStatic/public/configFile.js"></script>
<script src="${ctx}/layui/layui.js"></script>
<script>
    //一般直接写在一个js文件中
    layui.config({
        base: serverPath.qbdmsPath + staticPath.qbdmsPath //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','table', 'form', 'common','publicMethods','jquery','layer','laydate','propsHandle'], function () {
        var table = layui.table;
        var form = layui.form;
        var common = layui.common;
        var publicMethods = layui.publicMethods;
        var $ = layui.jquery;
        var layer = layui.layer;
        var laydate = layui.laydate;
        var propsHandle = layui.propsHandle;
        var defProps = {
                //viewMould: 'form/formDef/view/formDesign/moulds/', // 组件模块 存放文件 *****
                viewMould: 'moulds/', // 组件模块 存放文件 *****
                selectorBtn: '.selectorBtn'
            },
            temQuery = new propsHandle();  // 实例化模板功能部分
        temQuery.initTem({
            selectorBtn: defProps.selectorBtn,
            selectorTemPath: setter.views + defProps.viewMould
        });
        common.tableSort('wQbdFlightJcTable');

        var tableH=publicMethods.tabHeight();

        //第一个实例
        table.render({
            elem: '#wQbdFlightJcTable'
            , height: tableH
            , url: '${ctx}/qbdms/wQbdFlightJc/groupList'
            ,page: publicMethods.pageFun() //开启分页
            ,defaultToolbar: ['']
            , toolbar: '#wQbdFlightJcHeaderToolsBar'
            , method: 'post'
            , autoSort: false //是否排序
            ,limit:20
            , cols: [[ //表头
                {type: 'checkbox'}
                ,{field: 'sn', type: 'numbers', title: '序号' }
                , {
                    field: 'nd',
                    title: '年度',
                    width: 80,
                    sort: false,
                    sortname: 'nd',
                    templet: function (d) {
                        return publicMethods.timeData(d.nd).substr(0, 4);
                    }
                }
                , {field: 'xhmc', title: '型号名称', sort: false, sortname: 'xhmc',minWidth: '140'}
                , {
                    field: 'secret',
                    title: '密级',
                    minWidth: 80,
                    sort: false,
                    sortname: 'secret',
                    templet: function (d) {

                        return common.parsePrivacyLevel(d.secret);
                    }
                }
                , {field: 'ztswmc', title: '总体单位名称', minWidth: 140, sort: false, sortname: 'zgbm'}
                , {field: 'fxsymc', title: '飞行试验名称', minWidth: 140, sort: false, sortname: 'fxsymc'}
                ,
                {field: 'jhjlzed', title: '计划奖励总额度（万元）', minWidth: 190, sort: false, sortname: 'fxsymc',align: 'right',templet:function (d) {
                        if (d.jhjlzed == null){
                            return '<span style="color:#F07878">'+0+'</span>';
                        }else{
                            return '<span style="color:#F07878">'+d.jhjlzed+'</span>';
                        }
                    }}
                ,
                {field: 'jhcfzed', title: '计划处罚总额度（万元）', minWidth: 190, sort: false, sortname: 'fxsymc',align: 'right',templet:function (d) {
                        if (d.jhcfzed == null){
                            return '<span style="color:#F07878">'+0+'</span>';
                        }else{
                            return '<span style="color:#F07878">'+d.jhcfzed+'</span>';
                        }
                    }}
                , {field: 'jlswmc', title: '奖惩单位',align: 'left', minWidth: 140, sort: false, sortname: 'sfsy',templet: '#jlswmc'}
                , {field: 'fpbl', title: '分配比例',align: 'right', minWidth: 140, sort: false,templet: '#fpbl'}
                , {field: 'sjjled', title: '实际奖励额度（万元）', minWidth: 190, sort: false, sortname: 'SJJLED',templet: '#sjjled',align: 'right'}
                , {field: 'sjcfed', title: '实际处罚额度（万元）', minWidth: 40, sort: false, sortname: 'SJCFED',templet: '#sjcfed',align: 'right'}
                , {field: 'syjg', title: '试验结果', minWidth: 80, sort: false, templet:'#syjg',align: 'right'}
                , {
                    fixed: 'right',
                    title: '管理',
                    toolbar: '#wQbdFlightJcRightToolsBar'
                }
            ]], done: function () {
                table.resize('wQbdFlightJcTable');
                common.tableSelectCon('.ccpui-enterSel .layui-form input', 'a[lay-event=query]',
                    '.ccpui-enterSel');

            },parseData: function(res){ //res 即为原始返回的数据
                common.parseDataList(res,['ztswmc','syjg']);
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.count, //解析数据长度
                    "data": res.data //解析数据列表
                };
            }
        });

        //-- 初始化 数据字典 开始 --------------------------------------------------------------
        var xhdhList = eval('${xhmcList}')||[];
        common.initDicData("Q_xhmc_SL", xhdhList);
        //-- 初始化 数据字典 结束 --------------------------------------------------------------
        //list页面初始化展开按钮tips展示（展开按钮类名）
        publicMethods.tipsAuto('.screen')
        //筛选条件初始化（页面表格的Id，是否初始化（true、false））
        common.initScreenTop('wQbdFlightJcTable',true);
        dateReflash()
        function dateReflash() {
            publicMethods.reflashDate({startName:'.start_time1',endName:'.end_time1'},"year");
            //渲染年份选择
            var dateTimeFiledLen = $(".dateTimeFiled");
            var currentDate = new Date();
            var currentYear = currentDate.getFullYear();
            for(var i=0;i<dateTimeFiledLen.length;i++){
                laydate.render({
                    elem: dateTimeFiledLen[i] //指定元素
                    ,type: 'year'
                    ,trigger: 'click'
                    ,min:'1980-1-1'
                });
            }
        }

        function reflashQuery(isClear) {
            common.tableConditionRender("wQbdFlightJcTable","wQbdFlightJcQueryForm",{where:{}},isClear);
            //-- 初始化 数据字典 开始 --------------------------------------------------------------
            var xhdhList = eval('${xhmcList}')||[];
            common.initDicData("Q_xhmc_SL", xhdhList);
            //-- 初始化 数据字典 结束 --------------------------------------------------------------
        }

        table.on('toolbar(wQbdFlightJcTable)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            var data = checkStatus.data;
            var _this = this;
            switch (obj.event) {
                case 'add':
                    window.location.href =  "${ctx}/qbdms/wQbdFlightJc/view/add";
                    break;
                case 'delete':
                    var array = "";
                    for (var i = 0; i < data.length; i++) {
                        array+=data[i].id+",";
                    }
                    delFun(data,array);
                    break;
                case 'export':
                function open(url , param){
                    var curUrl = url;
                    layer.open({
                        type: 2,
                        area: ['700px', '550px'],
                        title: ['自定义导出', 'font-size:14px;'],
                        btnAlign: 'c',
                        skin: 'qbdms-layerFormBtn',
                        content: '${ctx}/qbdms/wQbdFlightJc/view/processExport',
                        btn: ['确定', '取消'],
                        yes: function(index, layero){
                            url = curUrl;
                            var iframeWin = window["layui-layer-iframe" + index];
                            var data = iframeWin.getData();
                            if(data){
                                url = url + "?data=" + JSON.stringify(data) + param;
                                window.location.href = encodeURI(url)
                            }
                        }
                    });
                }
                    if (data.length == 0) {
                        layer.confirm(publicMethods.confirmStyle('还没有选择，是否导出全部？'),{title: false,skin: 'confirm-class'}, function (index) {
                            layer.close(index);
                            var url = '${ctx}/qbdms/wQbdFlightJc/processExportData';
                            var param = "";
                            $("form[lay-filter='wQbdFlightJcQueryForm']").find(".filter-value").each(function(i,value) {
                                param += "&"+this.name+"="+this.value
                            });
                            open(url , param);
                        });
                    } else {
                        layer.confirm(publicMethods.confirmStyle('确定导出吗？'),{title: false,skin: 'confirm-class'}, function (index) {
                            layer.close(index);
                            var ids = [];
                            for (var i = 0; i < data.length; i++) {
                                ids.push(data[i].id);
                            }
                            var url = '${ctx}/qbdms/wQbdFlightJc/processExportData';
                            open(url , "&id="+ids);
                        });
                    }
                    break;
                case "import":
                    common.importInit('wQbdFlightJcTable',"/qbdms/wQbdFlightJc/importData",false,"");
                    dateReflash();
                    break;
                case "screen":
                    common.initScreenTop('wQbdFlightJcTable');
                    dateReflash();
                    form.render();
                    break;
                case "query":
                    reflashQuery(false);
                    dateReflash();
                    break;
                case "clears":
                    reflashQuery(true);
                    dateReflash();
                    break;

            };
        });

        table.on('tool(wQbdFlightJcTable)', function(obj) {
            var data = obj.data, //获得当前行数据
                    layEvent = obj.event; //获得 lay-event 对应的值
            switch(layEvent){
                case "edit":
                    alert(data.id);
                    // layer.open({
                    //     type: 2,
                    //     area: ['500px', '600px'],
                    //     title: ['修改数据'],
                    // content: serverPath.qbdmsPath + '/qbdms/wQbdFlightJc/view/add?id='+data.id
                    // });
                    break;
                case "particulars":
                    window.location.href = '${ctx}/qbdms/wQbdFlightJc/view/particularsprocess?id='+data.refid
                    break;
                case "del":
                    delFun(data,data.id);
                    break;
                case "feedback":
                    window.location.href = '${ctx}/qbdms/wQbdFlightJc/view/feedback?id='+data.id;
                    break;
            }
        });

        function delFun(data,id) {
            if (data.length === 0) {
                layer.confirm(publicMethods.confirmStyle("请先选择一行数据!"),{title: false,skin: 'confirm-class'});
            } else {
                layer.confirm(publicMethods.confirmStyle('确定删除当前数据吗?'),{title: false,skin: 'confirm-class'}, function (index) {
                    layer.close(index);
                    $.ajax({
                        url: serverPath.qbdmsPath + "/qbdms/wQbdFlightJc/del",
                        type: "post",
                        data: {id:id},
                        dataType: 'json',
                        success: function (data) {
                            layer.confirm(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'});
                            //执行重载
                            reflashQuery(true);
                            dateReflash();
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            layer.confirm(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'});
                            //执行重载
                            reflashQuery(true);
                            dateReflash();
                        }
                    })
                })
            }
        }

        window.Initialization = function () {
            reflashQuery(false);
            dateReflash();
        };
        /*刷新时间控件*/
        dateReflash();
        common.tableSort("wQbdFlightJcTable",{show:dateReflash});

    });
</script>
</body>
</html>